/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.colswe.solestac.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Operador
 */
@Entity
@Table(name = "PROGRAM")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Program.findAll", query = "SELECT p FROM Program p"),
    @NamedQuery(name = "Program.findById", query = "SELECT p FROM Program p WHERE p.id = :id"),
    @NamedQuery(name = "Program.findByName", query = "SELECT p FROM Program p WHERE p.name = :name") })
public class Program implements Serializable {
    /**Version of the Serializable interface.
     */
    private static final long serialVersionUID = 1L;
    /**ID from tue Program.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;
    /**Name form the Program.
     */
    @Column(name = "NAME")
    private String name;
    /**Students form the Program.
     */
    @OneToMany(mappedBy = "programId")
    private List<Student> studentList;

    /**Default constructor.
     */
    public Program() {
    }

    /**Constructor using the Id.
     * @param newId The new value
     */
    public Program(final Long newId) {
        this.id = newId;
    }

    /**Getter for Id.
     * @return The Id value
     */
    public Long getId() {
        return id;
    }

    /**Setter for Id.
     * @param newId The new value
     */
    public void setId(final Long newId) {
        this.id = newId;
    }

    /**Getter for Name.
     * @return The Name value.
     */
    public String getName() {
        return name;
    }

    /**Setter for Name.
     * @param newName The new value
     */
    public void setName(final String newName) {
        this.name = newName;
    }

    /**Getter for the Students List.
     * @return The StudentList
     */
    @XmlTransient
    public List<Student> getStudentList() {
        return studentList;
    }

    /**Setter for the Students List.
     * @param newStudentList The new StudentList
     */
    public void setStudentList(final List<Student> newStudentList) {
        this.studentList = newStudentList;
    }

    /**Assignment of the hash code.
     * @return The hash
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    /**Compare two Programm objects based on the Id.
     * @param object The object to compare
     * @return The result of the comparison.
     */
    @Override
    public boolean equals(final Object object) {
        if (!(object instanceof Program)) {
            return false;
        }
        Program other = (Program) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    /**Convert to string using the Id.
     * @return The string
     */
    @Override
    public String toString() {
        return "org.colswe.solestac.entity.Program[ id=" + id + " ]";
    }
}
